// powrspiral.txt. Use it to deactivate it. If player has enough Mechanics skill,
// it just turns off. Otherwise, it explodes.
// Cell 0 - Mechanics skill to deactivate it.
// Cell 1,2 - Stuff done flag which is set to 1 when it is off.
// Cell 3 - Num of d10 explosion does. Defaults to 12.
// Cell 4 - vulnerable to control key. If 1, having control key makes it just shut off.
// Cell 5 - cant turn it off without mechanics skill at least 2 less than difficulty

beginobjectscript;

variables;
short cur_tick;
short r1;
short exploding = 0;
short damage = 0;
short warned_once = 0;

body;

beginstate INIT_STATE;
	break;

beginstate DEAD_STATE;

break;

beginstate START_STATE; 
		if (gf(58,11) == 0) {
			if (get_ran(1,0,100) < 40)
				create_text_bubble("Hummmm ...");
			
			//if (get_ran(1,0,100) < 40)
			//	run_sparkles_on_object(ME,17,5,1);							
			}
	
	cur_tick = get_current_tick();
	if (gf(58,11) > 0)
		set_state(5);
	
break;

beginstate 5;
	create_text_bubble("Spark! Hiss!");
	if (cur_tick != get_current_tick()) {
		cur_tick = get_current_tick();
		set_state(6);
		}
break;

beginstate 6;
	create_text_bubble("Smoke! Spark!");
	if (cur_tick != get_current_tick()) {
		cur_tick = get_current_tick();
		set_state(7);
		}
break;

beginstate 7;
	set_flag(58,10,1);
	
	set_attitude(43,10);

	set_terrain(54,52,204);
	set_terrain(54,53,205);

	play_sound(103);
		
	r1 = 2000 + get_ran(1,0,1000);
	damage_nearby(r1,8,1,2);
	spray_missiles(58,8,8);

	kill_object(ME,0);

	damage_char(43,6000,0);
	
	begin_talk_mode(114);
break;

beginstate USE_STATE;
	begin_talk_mode(110);

break;
